package info.techgeek.labs.StringConcatenation;

public class StringConcatTest 
{ 
    public static void main(String a[]) 
    { 
        long t = System.currentTimeMillis(); 
        int limit = 500000;
        for(int i =0;i<limit;i++) 
        { 
            String s = "Hai" + i; 
            System.out.println(s);
        } 
        System.out.println("Time Taken using + operator :" +( System.currentTimeMillis() -t)); 
        t = System.currentTimeMillis(); 
        for(int i =0;i<limit;i++) 
        { 
            StringBuffer buffer = new StringBuffer("Hai"); 
            String s = buffer.append(i).toString(); 
            System.out.println(s);
        } 
        System.out.println("Time Taken using buffer:" +( System.currentTimeMillis() -t)); 
        t = System.currentTimeMillis(); 
        
        for(int i =0;i<limit;i++) 
        { 
            String s = "hai"; 
            s+=i; 
            System.out.println(s);
        } 
        System.out.println("Time Taken using +=" +( System.currentTimeMillis() -t)); 
    } 

} 

